- return unless @new_license.present?

%section.settings#js-add-license-toggle{ class: ('expanded' if expanded_by_default?) }
  .settings-header{ data: { testid: 'expand_add_license_header' } }
    %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
      = _('Add License')
    = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle', data: { testid: 'expand-add-license-button' } }) do
      = expanded_by_default? ? _('Collapse') : _('Expand')
    %p.gl-text-secondary
      - if License.current
        = _('To continue using GitLab Enterprise Edition, upload the %{codeOpen}.gitlab-license%{codeClose} file or enter the license key you have received from GitLab Inc.').html_safe % {codeOpen: '<code>'.html_safe, codeClose: '</code>'.html_safe}
      - else
        = _('To start using GitLab Enterprise Edition, upload the %{codeOpen}.gitlab-license%{codeClose} file or enter the license key you have received from GitLab Inc.').html_safe % {codeOpen: '<code>'.html_safe, codeClose: '</code>'.html_safe}

  .settings-content
    - eula_url = "https://#{ApplicationHelper.promo_host}/terms/#subscription"
    - eula_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: eula_url }

    %hr
    = gitlab_ui_form_for @new_license, url: admin_license_path, html: { name: 'addLicense', multipart: true, class: 'fieldset-form', autocomplete: 'off' } do |f|
      .form-group
        = f.gitlab_ui_radio_component :license_type, :file, _('Upload %{file_name} file').html_safe % { file_name: '<code>.gitlab-license</code>'.html_safe }, radio_options: { name: 'license_type', checked: @new_license.data.blank? }

        .form-group.license-file.gl-mt-4
          #js-license-new-app

        .gl-my-4
          = f.gitlab_ui_radio_component :license_type, :key, _('Enter license key'), radio_options: { checked: @new_license.data.present?, name: 'license_type', data: { qa_selector: 'license_type_key_radio' } }
        .form-group.license-key.hidden
          = f.label :data, _('License key'), class: 'gl-sr-only'
          = f.text_area :data, class: "form-control license-key-field", data: { qa_selector: 'license_key_field' }, rows: 20

      %hr

      %h4.gl-font-base= _("Terms of service")

      .form-group
        = render Pajamas::CheckboxTagComponent.new(name: :accept_eula,
          value: nil,
          checked: false,
          checkbox_options: { data: { qa_selector: 'accept_eula_checkbox'} }) do |c|
          - c.with_label do
            = _('Unless otherwise agreed to in writing with GitLab, by clicking "Upload License" you agree that your use of GitLab Software is subject to the %{eula_link_start}Terms of Service%{eula_link_end}.').html_safe % { eula_link_start: eula_link_start, eula_url: eula_url, eula_link_end: '</a>'.html_safe }
      .form-actions
        = f.submit _('Add license'), pajamas_button: true, data: { qa_selector: 'license_upload_button' }, disabled: true
